{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import pandas as pd\n",
    "from math import comb\n",
    "import pickle"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Parameters**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "v=30\n",
    "lam=.125\n",
    "c=1\n",
    "T=10\n",
    "N=4\n",
    "\n",
    "period=10"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Last Period (FS>0)**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def f_enterF(pf,y,N):\n",
    "    return (comb(N-2,y)*((pf**y)*(1-pf)**(N-2-y)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def f_enterL(pf,y,N):\n",
    "    return (comb(N-1,y)*((pf**y)*(1-pf)**(N-1-y)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def last_period_0(FS,initial):\n",
    "    \n",
    "    p=initial[0]\n",
    "    old=5\n",
    "    \n",
    "    j=0\n",
    "    while ((abs(p-old))>1e-6):\n",
    "        vDraw=v*sum([comb(N-1,y)*(p**y)*((1-p)**(N-1-y))*(1/(y+1)) for y in range(N)])-c\n",
    "\n",
    "        vNoDraw=v*((1-p)**(N-1))*(1/N)\n",
    "\n",
    "        old=p\n",
    "\n",
    "        #Gets too big, have to adjust for this\n",
    "        p=(np.exp(mu*(vDraw-max(vDraw,vNoDraw))))/(np.exp(mu*(vDraw-max(vDraw,vNoDraw)))+np.exp(mu*(vNoDraw-max(vDraw,vNoDraw))))\n",
    "    \n",
    "    payoff=p*vDraw + (1-p)*vNoDraw\n",
    "    \n",
    "    return p,payoff"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def last_period(FS,initial):\n",
    "    \n",
    "    pl=initial[0]\n",
    "    pf=initial[1]\n",
    "\n",
    "    oldl=5\n",
    "    oldf=5\n",
    "    \n",
    "    epsilon=1\n",
    "    \n",
    "    #Follower\n",
    "    iteration=0\n",
    "    while ((abs(pl-oldl)+abs(pf-oldf))>1e-6)&(iteration<6):\n",
    "        vFollowerDrawFirst=v*(1-pl)*(sum([(f_enterF(pf,y,N))*sum([comb(y,z)*(1/(z+1))*((1-FS)**(z+1))*(FS**(y-z)) for z in range(y+1)]) for y in range(N-1)]))\n",
    "        vFollowerDrawSecond=v*pl*(sum([(f_enterF(pf,y,N))*sum([comb(y,z)*(1/(z+1))*((1-FS)**(z+1))*(FS**(y+1-z)) for z in range(y+1)]) for y in range(N-1)]))\n",
    "        vFollowerDrawThird=v*pl*(sum([(f_enterF(pf,y,N))*sum([comb(y,z)*(1/(z+2))*((1-FS)**(z+2))*(FS**(y-z)) for z in range(y+1)]) for y in range(N-1)]))\n",
    "        vFollowerDraw=vFollowerDrawFirst+vFollowerDrawSecond+vFollowerDrawThird-c\n",
    "        vFollowerNoDraw=0\n",
    "\n",
    "        #Leader\n",
    "\n",
    "        vLeaderNoDraw=v*sum([f_enterL(pf,y,N)*(FS**y) for y in range(N)])\n",
    "        vLeaderDrawFirst=v*sum([f_enterL(pf,y,N)*(FS**(y+1)) for y in range(N)])\n",
    "        vLeaderDrawSecond=v*sum([f_enterL(pf,y,N)*sum([comb(y,z)*(1/(z+1))*((1-FS)**(z+1))*((FS)**(y-z)) for z in range(y+1)]) for y in range(N)])\n",
    "        vLeaderDraw=vLeaderDrawFirst+vLeaderDrawSecond-c\n",
    "\n",
    "        oldl=pl\n",
    "        oldf=pf\n",
    "\n",
    "        #Gets too big, have to adjust for this\n",
    "        pfU=(np.exp(mu*(vFollowerDraw-max(vFollowerDraw,vFollowerNoDraw))))/(np.exp(mu*(vFollowerDraw-max(vFollowerDraw,vFollowerNoDraw)))+np.exp(mu*(vFollowerNoDraw-max(vFollowerDraw,vFollowerNoDraw))))\n",
    "        plU=(np.exp(mu*(vLeaderDraw-max(vLeaderDraw,vLeaderNoDraw))))/(np.exp(mu*(vLeaderDraw-max(vLeaderDraw,vLeaderNoDraw)))+np.exp(mu*(vLeaderNoDraw-max(vLeaderDraw,vLeaderNoDraw))))\n",
    "        \n",
    "        pl=(1-epsilon)*oldl + epsilon*plU\n",
    "        pf=(1-epsilon)*oldf + epsilon*pfU\n",
    "        \n",
    "        iteration=iteration+1\n",
    "        \n",
    "    epsilon=.01\n",
    "    while ((abs(pl-oldl)+abs(pf-oldf))>1e-6):\n",
    "        vFollowerDrawFirst=v*(1-pl)*(sum([(f_enterF(pf,y,N))*sum([comb(y,z)*(1/(z+1))*((1-FS)**(z+1))*(FS**(y-z)) for z in range(y+1)]) for y in range(N-1)]))\n",
    "        vFollowerDrawSecond=v*pl*(sum([(f_enterF(pf,y,N))*sum([comb(y,z)*(1/(z+1))*((1-FS)**(z+1))*(FS**(y+1-z)) for z in range(y+1)]) for y in range(N-1)]))\n",
    "        vFollowerDrawThird=v*pl*(sum([(f_enterF(pf,y,N))*sum([comb(y,z)*(1/(z+2))*((1-FS)**(z+2))*(FS**(y-z)) for z in range(y+1)]) for y in range(N-1)]))\n",
    "        vFollowerDraw=vFollowerDrawFirst+vFollowerDrawSecond+vFollowerDrawThird-c\n",
    "        vFollowerNoDraw=0\n",
    "\n",
    "        #Leader\n",
    "\n",
    "        vLeaderNoDraw=v*sum([f_enterL(pf,y,N)*(FS**y) for y in range(N)])\n",
    "        vLeaderDrawFirst=v*sum([f_enterL(pf,y,N)*(FS**(y+1)) for y in range(N)])\n",
    "        vLeaderDrawSecond=v*sum([f_enterL(pf,y,N)*sum([comb(y,z)*(1/(z+1))*((1-FS)**(z+1))*((FS)**(y-z)) for z in range(y+1)]) for y in range(N)])\n",
    "        vLeaderDraw=vLeaderDrawFirst+vLeaderDrawSecond-c\n",
    "\n",
    "        oldl=pl\n",
    "        oldf=pf\n",
    "\n",
    "        #Gets too big, have to adjust for this\n",
    "        pfU=(np.exp(mu*(vFollowerDraw-max(vFollowerDraw,vFollowerNoDraw))))/(np.exp(mu*(vFollowerDraw-max(vFollowerDraw,vFollowerNoDraw)))+np.exp(mu*(vFollowerNoDraw-max(vFollowerDraw,vFollowerNoDraw))))\n",
    "        plU=(np.exp(mu*(vLeaderDraw-max(vLeaderDraw,vLeaderNoDraw))))/(np.exp(mu*(vLeaderDraw-max(vLeaderDraw,vLeaderNoDraw)))+np.exp(mu*(vLeaderNoDraw-max(vLeaderDraw,vLeaderNoDraw))))\n",
    "        \n",
    "        pl=(1-epsilon)*oldl + epsilon*plU\n",
    "        pf=(1-epsilon)*oldf + epsilon*pfU\n",
    "                \n",
    "    payoffF=pf*vFollowerDraw + (1-pf)*vFollowerNoDraw\n",
    "    payoffL=pl*vLeaderDraw + (1-pl)*vLeaderNoDraw\n",
    "    \n",
    "    return pl,pf,payoffL,payoffF"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0 1.0 1.0\n",
      "0.001 1.0 1.0\n",
      "0.002 1.0 1.0\n",
      "0.003 1.0 1.0\n",
      "0.004 1.0 1.0\n",
      "0.005 1.0 1.0\n",
      "0.006 1.0 1.0\n",
      "0.007 1.0 1.0\n",
      "0.008 1.0 1.0\n",
      "0.009000000000000001 1.0 1.0\n",
      "0.01 1.0 1.0\n",
      "0.011 1.0 1.0\n",
      "0.012 1.0 1.0\n",
      "0.013000000000000001 1.0 1.0\n",
      "0.014 1.0 1.0\n",
      "0.015 1.0 1.0\n",
      "0.016 1.0 1.0\n",
      "0.017 1.0 1.0\n",
      "0.018000000000000002 1.0 1.0\n",
      "0.019 1.0 1.0\n",
      "0.02 1.0 1.0\n",
      "0.021 1.0 1.0\n",
      "0.022 1.0 1.0\n",
      "0.023 1.0 1.0\n",
      "0.024 1.0 1.0\n",
      "0.025 1.0 1.0\n",
      "0.026000000000000002 1.0 1.0\n",
      "0.027 1.0 1.0\n",
      "0.028 1.0 1.0\n",
      "0.029 1.0 1.0\n",
      "0.03 1.0 1.0\n",
      "0.031 1.0 1.0\n",
      "0.032 1.0 1.0\n",
      "0.033 1.0 1.0\n",
      "0.034 1.0 1.0\n",
      "0.035 1.0 1.0\n",
      "0.036000000000000004 1.0 1.0\n",
      "0.037 1.0 1.0\n",
      "0.038 1.0 1.0\n",
      "0.039 1.0 1.0\n",
      "0.04 1.0 1.0\n",
      "0.041 1.0 1.0\n",
      "0.042 1.0 1.0\n",
      "0.043000000000000003 1.0 1.0\n",
      "0.044 1.0 1.0\n",
      "0.045 1.0 1.0\n",
      "0.046 1.0 1.0\n",
      "0.047 1.0 1.0\n",
      "0.048 1.0 1.0\n",
      "0.049 1.0 1.0\n",
      "0.05 1.0 1.0\n",
      "0.051000000000000004 1.0 1.0\n",
      "0.052000000000000005 1.0 1.0\n",
      "0.053 1.0 1.0\n",
      "0.054 1.0 1.0\n",
      "0.055 1.0 1.0\n",
      "0.056 1.0 1.0\n",
      "0.057 1.0 1.0\n",
      "0.058 1.0 1.0\n",
      "0.059000000000000004 1.0 1.0\n",
      "0.06 1.0 1.0\n",
      "0.061 1.0 1.0\n",
      "0.062 1.0 1.0\n",
      "0.063 1.0 1.0\n",
      "0.064 1.0 1.0\n",
      "0.065 1.0 1.0\n",
      "0.066 1.0 1.0\n",
      "0.067 1.0 1.0\n",
      "0.068 1.0 1.0\n",
      "0.069 1.0 1.0\n",
      "0.07 1.0 1.0\n",
      "0.07100000000000001 1.0 1.0\n",
      "0.07200000000000001 1.0 1.0\n",
      "0.073 1.0 1.0\n",
      "0.074 1.0 1.0\n",
      "0.075 1.0 1.0\n",
      "0.076 1.0 1.0\n",
      "0.077 1.0 1.0\n",
      "0.078 1.0 1.0\n",
      "0.079 1.0 1.0\n",
      "0.08 1.0 1.0\n",
      "0.081 1.0 1.0\n",
      "0.082 1.0 1.0\n",
      "0.083 1.0 1.0\n",
      "0.084 1.0 1.0\n",
      "0.085 1.0 1.0\n",
      "0.08600000000000001 1.0 1.0\n",
      "0.08700000000000001 1.0 1.0\n",
      "0.088 1.0 1.0\n",
      "0.089 1.0 1.0\n",
      "0.09 1.0 1.0\n",
      "0.091 1.0 1.0\n",
      "0.092 1.0 1.0\n",
      "0.093 1.0 1.0\n",
      "0.094 1.0 1.0\n",
      "0.095 1.0 1.0\n",
      "0.096 1.0 1.0\n",
      "0.097 1.0 1.0\n",
      "0.098 1.0 1.0\n",
      "0.099 1.0 1.0\n",
      "0.1 1.0 1.0\n",
      "0.101 1.0 1.0\n",
      "0.10200000000000001 1.0 1.0\n",
      "0.10300000000000001 1.0 1.0\n",
      "0.10400000000000001 1.0 1.0\n",
      "0.105 1.0 1.0\n",
      "0.106 1.0 1.0\n",
      "0.107 1.0 1.0\n",
      "0.108 1.0 1.0\n",
      "0.109 1.0 1.0\n",
      "0.11 1.0 1.0\n",
      "0.111 1.0 1.0\n",
      "0.112 1.0 1.0\n",
      "0.113 1.0 1.0\n",
      "0.114 1.0 1.0\n",
      "0.115 1.0 1.0\n",
      "0.116 1.0 1.0\n",
      "0.117 1.0 1.0\n",
      "0.11800000000000001 1.0 1.0\n",
      "0.11900000000000001 1.0 1.0\n",
      "0.12 1.0 1.0\n",
      "0.121 1.0 1.0\n",
      "0.122 1.0 1.0\n",
      "0.123 1.0 1.0\n",
      "0.124 1.0 1.0\n",
      "0.125 1.0 1.0\n",
      "0.126 1.0 1.0\n",
      "0.127 1.0 1.0\n",
      "0.128 1.0 1.0\n",
      "0.129 1.0 1.0\n",
      "0.13 1.0 1.0\n",
      "0.131 1.0 1.0\n",
      "0.132 1.0 1.0\n",
      "0.133 1.0 1.0\n",
      "0.134 1.0 1.0\n",
      "0.135 1.0 1.0\n",
      "0.136 1.0 1.0\n",
      "0.137 1.0 1.0\n",
      "0.138 1.0 1.0\n",
      "0.139 1.0 1.0\n",
      "0.14 1.0 1.0\n",
      "0.14100000000000001 1.0 1.0\n",
      "0.14200000000000002 1.0 1.0\n",
      "0.14300000000000002 1.0 1.0\n",
      "0.14400000000000002 1.0 1.0\n",
      "0.145 1.0 1.0\n",
      "0.146 1.0 1.0\n",
      "0.147 1.0 1.0\n",
      "0.148 1.0 1.0\n",
      "0.149 1.0 1.0\n",
      "0.15 1.0 1.0\n",
      "0.151 1.0 1.0\n",
      "0.152 1.0 1.0\n",
      "0.153 1.0 1.0\n",
      "0.154 1.0 1.0\n",
      "0.155 1.0 1.0\n",
      "0.156 1.0 1.0\n",
      "0.157 1.0 1.0\n",
      "0.158 1.0 1.0\n",
      "0.159 1.0 1.0\n",
      "0.16 1.0 1.0\n",
      "0.161 1.0 1.0\n",
      "0.162 1.0 1.0\n",
      "0.163 1.0 1.0\n",
      "0.164 1.0 1.0\n",
      "0.165 1.0 1.0\n",
      "0.166 1.0 1.0\n",
      "0.167 1.0 1.0\n",
      "0.168 1.0 1.0\n",
      "0.169 1.0 1.0\n",
      "0.17 1.0 1.0\n",
      "0.171 1.0 1.0\n",
      "0.17200000000000001 1.0 1.0\n",
      "0.17300000000000001 1.0 1.0\n",
      "0.17400000000000002 1.0 1.0\n",
      "0.17500000000000002 1.0 1.0\n",
      "0.176 1.0 1.0\n",
      "0.177 1.0 1.0\n",
      "0.178 1.0 1.0\n",
      "0.179 1.0 1.0\n",
      "0.18 1.0 1.0\n",
      "0.181 1.0 1.0\n",
      "0.182 1.0 1.0\n",
      "0.183 1.0 1.0\n",
      "0.184 1.0 1.0\n",
      "0.185 1.0 1.0\n",
      "0.186 1.0 1.0\n",
      "0.187 1.0 1.0\n",
      "0.188 1.0 1.0\n",
      "0.189 1.0 1.0\n",
      "0.19 1.0 1.0\n",
      "0.191 1.0 1.0\n",
      "0.192 1.0 1.0\n",
      "0.193 1.0 1.0\n",
      "0.194 1.0 1.0\n",
      "0.195 1.0 1.0\n",
      "0.196 1.0 1.0\n",
      "0.197 1.0 1.0\n",
      "0.198 1.0 1.0\n",
      "0.199 1.0 1.0\n",
      "0.2 1.0 1.0\n",
      "0.201 1.0 1.0\n",
      "0.202 1.0 1.0\n",
      "0.203 1.0 1.0\n",
      "0.20400000000000001 1.0 1.0\n",
      "0.20500000000000002 1.0 1.0\n",
      "0.20600000000000002 1.0 1.0\n",
      "0.20700000000000002 1.0 1.0\n",
      "0.20800000000000002 1.0 1.0\n",
      "0.209 1.0 1.0\n",
      "0.21 1.0 1.0\n",
      "0.211 1.0 1.0\n",
      "0.212 1.0 1.0\n",
      "0.213 1.0 1.0\n",
      "0.214 1.0 1.0\n",
      "0.215 1.0 1.0\n",
      "0.216 1.0 1.0\n",
      "0.217 1.0 1.0\n",
      "0.218 1.0 1.0\n",
      "0.219 1.0 1.0\n",
      "0.22 1.0 1.0\n",
      "0.221 1.0 1.0\n",
      "0.222 1.0 1.0\n",
      "0.223 1.0 1.0\n",
      "0.224 1.0 1.0\n",
      "0.225 1.0 1.0\n",
      "0.226 1.0 1.0\n",
      "0.227 1.0 1.0\n",
      "0.228 1.0 1.0\n",
      "0.229 1.0 1.0\n",
      "0.23 1.0 1.0\n",
      "0.231 1.0 1.0\n",
      "0.232 1.0 1.0\n",
      "0.233 1.0 1.0\n",
      "0.234 1.0 1.0\n",
      "0.23500000000000001 1.0 1.0\n",
      "0.23600000000000002 1.0 1.0\n",
      "0.23700000000000002 1.0 1.0\n",
      "0.23800000000000002 1.0 1.0\n",
      "0.23900000000000002 1.0 1.0\n",
      "0.24 1.0 1.0\n",
      "0.241 1.0 1.0\n",
      "0.242 1.0 1.0\n",
      "0.243 1.0 1.0\n",
      "0.244 1.0 1.0\n",
      "0.245 1.0 1.0\n",
      "0.246 1.0 1.0\n",
      "0.247 1.0 1.0\n",
      "0.248 1.0 1.0\n",
      "0.249 1.0 1.0\n",
      "0.25 1.0 1.0\n",
      "0.251 1.0 1.0\n",
      "0.252 1.0 1.0\n",
      "0.253 1.0 1.0\n",
      "0.254 1.0 1.0\n",
      "0.255 1.0 1.0\n",
      "0.256 1.0 1.0\n",
      "0.257 1.0 1.0\n",
      "0.258 1.0 1.0\n",
      "0.259 1.0 1.0\n",
      "0.26 1.0 1.0\n",
      "0.261 1.0 1.0\n",
      "0.262 1.0 1.0\n",
      "0.263 1.0 1.0\n",
      "0.264 1.0 1.0\n",
      "0.265 1.0 1.0\n",
      "0.266 1.0 1.0\n",
      "0.267 1.0 1.0\n",
      "0.268 1.0 1.0\n",
      "0.269 1.0 1.0\n",
      "0.27 1.0 1.0\n",
      "0.271 1.0 1.0\n",
      "0.272 1.0 1.0\n",
      "0.273 1.0 1.0\n",
      "0.274 1.0 1.0\n",
      "0.275 1.0 1.0\n",
      "0.276 1.0 1.0\n",
      "0.277 1.0 1.0\n",
      "0.278 1.0 1.0\n",
      "0.279 1.0 1.0\n",
      "0.28 1.0 1.0\n",
      "0.281 1.0 1.0\n",
      "0.28200000000000003 1.0 1.0\n",
      "0.28300000000000003 1.0 1.0\n",
      "0.28400000000000003 1.0 1.0\n",
      "0.28500000000000003 1.0 1.0\n",
      "0.28600000000000003 1.0 1.0\n",
      "0.28700000000000003 1.0 1.0\n",
      "0.28800000000000003 1.0 1.0\n",
      "0.289 1.0 1.0\n",
      "0.29 1.0 1.0\n",
      "0.291 1.0 1.0\n",
      "0.292 1.0 1.0\n",
      "0.293 1.0 1.0\n",
      "0.294 1.0 1.0\n",
      "0.295 1.0 1.0\n",
      "0.296 1.0 1.0\n",
      "0.297 1.0 1.0\n",
      "0.298 1.0 1.0\n",
      "0.299 1.0 1.0\n",
      "0.3 1.0 1.0\n",
      "0.301 1.0 1.0\n",
      "0.302 1.0 1.0\n",
      "0.303 1.0 1.0\n",
      "0.304 1.0 1.0\n",
      "0.305 1.0 1.0\n",
      "0.306 1.0 1.0\n",
      "0.307 1.0 1.0\n",
      "0.308 1.0 1.0\n",
      "0.309 1.0 1.0\n",
      "0.31 1.0 1.0\n",
      "0.311 1.0 1.0\n",
      "0.312 1.0 1.0\n",
      "0.313 1.0 1.0\n",
      "0.314 1.0 1.0\n",
      "0.315 1.0 1.0\n",
      "0.316 1.0 1.0\n",
      "0.317 1.0 1.0\n",
      "0.318 1.0 1.0\n",
      "0.319 1.0 1.0\n",
      "0.32 1.0 1.0\n",
      "0.321 1.0 1.0\n",
      "0.322 1.0 1.0\n",
      "0.323 1.0 1.0\n",
      "0.324 1.0 1.0\n",
      "0.325 1.0 1.0\n",
      "0.326 1.0 1.0\n",
      "0.327 1.0 1.0\n",
      "0.328 1.0 1.0\n",
      "0.329 1.0 1.0\n",
      "0.33 1.0 1.0\n",
      "0.331 1.0 1.0\n",
      "0.332 1.0 1.0\n",
      "0.333 1.0 1.0\n",
      "0.334 1.0 1.0\n",
      "0.335 1.0 1.0\n",
      "0.336 1.0 1.0\n",
      "0.337 1.0 1.0\n",
      "0.338 1.0 1.0\n",
      "0.339 1.0 1.0\n",
      "0.34 1.0 1.0\n",
      "0.341 1.0 1.0\n",
      "0.342 1.0 1.0\n",
      "0.343 1.0 1.0\n",
      "0.34400000000000003 1.0 1.0\n",
      "0.34500000000000003 1.0 1.0\n",
      "0.34600000000000003 1.0 1.0\n",
      "0.34700000000000003 1.0 1.0\n",
      "0.34800000000000003 1.0 1.0\n",
      "0.34900000000000003 1.0 1.0\n",
      "0.35000000000000003 1.0 1.0\n",
      "0.35100000000000003 1.0 1.0\n",
      "0.352 1.0 1.0\n",
      "0.353 1.0 1.0\n",
      "0.354 1.0 1.0\n",
      "0.355 1.0 1.0\n",
      "0.356 1.0 1.0\n",
      "0.357 1.0 1.0\n",
      "0.358 1.0 1.0\n",
      "0.359 1.0 1.0\n",
      "0.36 1.0 1.0\n",
      "0.361 1.0 1.0\n",
      "0.362 1.0 1.0\n",
      "0.363 1.0 1.0\n",
      "0.364 1.0 1.0\n",
      "0.365 1.0 1.0\n",
      "0.366 1.0 1.0\n",
      "0.367 1.0 1.0\n",
      "0.368 1.0 1.0\n",
      "0.369 1.0 1.0\n",
      "0.37 1.0 1.0\n",
      "0.371 1.0 1.0\n",
      "0.372 1.0 1.0\n",
      "0.373 1.0 1.0\n",
      "0.374 1.0 1.0\n",
      "0.375 1.0 1.0\n",
      "0.376 1.0 1.0\n",
      "0.377 1.0 1.0\n",
      "0.378 1.0 1.0\n",
      "0.379 1.0 1.0\n",
      "0.38 1.0 1.0\n",
      "0.381 1.0 1.0\n",
      "0.382 1.0 1.0\n",
      "0.383 1.0 1.0\n",
      "0.384 1.0 1.0\n",
      "0.385 1.0 1.0\n",
      "0.386 1.0 1.0\n",
      "0.387 1.0 1.0\n",
      "0.388 1.0 1.0\n",
      "0.389 1.0 1.0\n",
      "0.39 1.0 1.0\n",
      "0.391 1.0 1.0\n",
      "0.392 1.0 1.0\n",
      "0.393 1.0 1.0\n",
      "0.394 1.0 1.0\n",
      "0.395 1.0 1.0\n",
      "0.396 1.0 1.0\n",
      "0.397 1.0 1.0\n",
      "0.398 1.0 1.0\n",
      "0.399 1.0 1.0\n",
      "0.4 1.0 1.0\n",
      "0.401 1.0 1.0\n",
      "0.402 1.0 1.0\n",
      "0.403 1.0 1.0\n",
      "0.404 1.0 1.0\n",
      "0.405 1.0 1.0\n",
      "0.406 1.0 1.0\n",
      "0.40700000000000003 1.0 1.0\n",
      "0.40800000000000003 1.0 1.0\n",
      "0.40900000000000003 1.0 1.0\n",
      "0.41000000000000003 1.0 1.0\n",
      "0.41100000000000003 1.0 1.0\n",
      "0.41200000000000003 1.0 1.0\n",
      "0.41300000000000003 1.0 1.0\n",
      "0.41400000000000003 1.0 1.0\n",
      "0.41500000000000004 1.0 1.0\n",
      "0.41600000000000004 1.0 1.0\n",
      "0.417 1.0 1.0\n",
      "0.418 1.0 1.0\n",
      "0.419 1.0 1.0\n",
      "0.42 1.0 1.0\n",
      "0.421 1.0 1.0\n",
      "0.422 1.0 1.0\n",
      "0.423 1.0 1.0\n",
      "0.424 1.0 1.0\n",
      "0.425 1.0 1.0\n",
      "0.426 1.0 1.0\n",
      "0.427 1.0 1.0\n",
      "0.428 1.0 1.0\n",
      "0.429 1.0 1.0\n",
      "0.43 1.0 1.0\n",
      "0.431 1.0 1.0\n",
      "0.432 1.0 1.0\n",
      "0.433 1.0 1.0\n",
      "0.434 1.0 1.0\n",
      "0.435 1.0 1.0\n",
      "0.436 1.0 1.0\n",
      "0.437 1.0 1.0\n",
      "0.438 1.0 1.0\n",
      "0.439 1.0 1.0\n",
      "0.44 1.0 1.0\n",
      "0.441 1.0 1.0\n",
      "0.442 1.0 1.0\n",
      "0.443 1.0 1.0\n",
      "0.444 1.0 1.0\n",
      "0.445 1.0 1.0\n",
      "0.446 1.0 1.0\n",
      "0.447 1.0 1.0\n",
      "0.448 1.0 1.0\n",
      "0.449 1.0 1.0\n",
      "0.45 1.0 1.0\n",
      "0.451 1.0 1.0\n",
      "0.452 1.0 1.0\n",
      "0.453 1.0 1.0\n",
      "0.454 1.0 1.0\n",
      "0.455 1.0 1.0\n",
      "0.456 1.0 1.0\n",
      "0.457 1.0 1.0\n",
      "0.458 1.0 1.0\n",
      "0.459 1.0 1.0\n",
      "0.46 1.0 1.0\n",
      "0.461 1.0 1.0\n",
      "0.462 1.0 1.0\n",
      "0.463 1.0 1.0\n",
      "0.464 1.0 1.0\n",
      "0.465 1.0 1.0\n",
      "0.466 1.0 1.0\n",
      "0.467 1.0 1.0\n",
      "0.468 1.0 1.0\n",
      "0.46900000000000003 1.0 1.0\n",
      "0.47000000000000003 1.0 1.0\n",
      "0.47100000000000003 1.0 1.0\n",
      "0.47200000000000003 1.0 1.0\n",
      "0.47300000000000003 1.0 1.0\n",
      "0.47400000000000003 1.0 1.0\n",
      "0.47500000000000003 1.0 1.0\n",
      "0.47600000000000003 1.0 1.0\n",
      "0.47700000000000004 1.0 1.0\n",
      "0.47800000000000004 1.0 1.0\n",
      "0.47900000000000004 1.0 1.0\n",
      "0.48 1.0 1.0\n",
      "0.481 1.0 1.0\n",
      "0.482 1.0 1.0\n",
      "0.483 1.0 1.0\n",
      "0.484 1.0 1.0\n",
      "0.485 1.0 1.0\n",
      "0.486 1.0 1.0\n",
      "0.487 1.0 1.0\n",
      "0.488 1.0 1.0\n",
      "0.489 1.0 1.0\n",
      "0.49 1.0 1.0\n",
      "0.491 1.0 1.0\n",
      "0.492 1.0 1.0\n",
      "0.493 1.0 1.0\n",
      "0.494 1.0 1.0\n",
      "0.495 1.0 1.0\n",
      "0.496 1.0 1.0\n",
      "0.497 1.0 1.0\n",
      "0.498 1.0 1.0\n",
      "0.499 1.0 1.0\n",
      "0.5 1.0 1.0\n",
      "0.501 1.0 1.0\n",
      "0.502 1.0 1.0\n",
      "0.503 1.0 1.0\n",
      "0.504 1.0 1.0\n",
      "0.505 1.0 1.0\n",
      "0.506 1.0 1.0\n",
      "0.507 1.0 1.0\n",
      "0.508 1.0 1.0\n",
      "0.509 1.0 1.0\n",
      "0.51 1.0 1.0\n",
      "0.511 1.0 1.0\n",
      "0.512 1.0 1.0\n",
      "0.513 1.0 1.0\n",
      "0.514 1.0 1.0\n",
      "0.515 1.0 1.0\n",
      "0.516 1.0 1.0\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.517 1.0 1.0\n",
      "0.518 1.0 1.0\n",
      "0.519 1.0 1.0\n",
      "0.52 1.0 1.0\n",
      "0.521 1.0 1.0\n",
      "0.522 1.0 1.0\n",
      "0.523 1.0 1.0\n",
      "0.524 1.0 1.0\n",
      "0.525 1.0 1.0\n",
      "0.526 1.0 1.0\n",
      "0.527 1.0 1.0\n",
      "0.528 1.0 1.0\n",
      "0.529 1.0 1.0\n",
      "0.53 1.0 1.0\n",
      "0.531 1.0 1.0\n",
      "0.532 1.0 1.0\n",
      "0.533 1.0 1.0\n",
      "0.534 1.0 1.0\n",
      "0.535 1.0 1.0\n",
      "0.536 1.0 1.0\n",
      "0.537 1.0 1.0\n",
      "0.538 1.0 1.0\n",
      "0.539 1.0 1.0\n",
      "0.54 1.0 1.0\n",
      "0.541 1.0 1.0\n",
      "0.542 1.0 1.0\n",
      "0.543 1.0 1.0\n",
      "0.544 1.0 1.0\n",
      "0.545 1.0 1.0\n",
      "0.546 1.0 1.0\n",
      "0.547 1.0 1.0\n",
      "0.548 1.0 1.0\n",
      "0.549 1.0 1.0\n",
      "0.55 1.0 1.0\n",
      "0.551 1.0 1.0\n",
      "0.552 1.0 1.0\n",
      "0.553 1.0 1.0\n",
      "0.554 1.0 1.0\n",
      "0.555 1.0 1.0\n",
      "0.556 1.0 1.0\n",
      "0.557 1.0 1.0\n",
      "0.558 1.0 1.0\n",
      "0.559 1.0 1.0\n",
      "0.56 1.0 1.0\n",
      "0.561 1.0 1.0\n",
      "0.562 1.0 1.0\n",
      "0.5630000000000001 1.0 1.0\n",
      "0.5640000000000001 1.0 1.0\n",
      "0.5650000000000001 1.0 1.0\n",
      "0.5660000000000001 1.0 1.0\n",
      "0.5670000000000001 1.0 1.0\n",
      "0.5680000000000001 1.0 1.0\n",
      "0.5690000000000001 1.0 1.0\n",
      "0.5700000000000001 1.0 1.0\n",
      "0.5710000000000001 1.0 1.0\n",
      "0.5720000000000001 1.0 1.0\n",
      "0.5730000000000001 1.0 1.0\n",
      "0.5740000000000001 1.0 1.0\n",
      "0.5750000000000001 1.0 1.0\n",
      "0.5760000000000001 1.0 1.0\n",
      "0.577 1.0 1.0\n",
      "0.578 1.0 1.0\n",
      "0.579 1.0 1.0\n",
      "0.58 1.0 1.0\n",
      "0.581 1.0 1.0\n",
      "0.582 1.0 1.0\n",
      "0.583 1.0 1.0\n",
      "0.584 1.0 1.0\n",
      "0.585 1.0 1.0\n",
      "0.586 1.0 1.0\n",
      "0.587 1.0 1.0\n",
      "0.588 1.0 1.0\n",
      "0.589 1.0 1.0\n",
      "0.59 1.0 1.0\n",
      "0.591 1.0 1.0\n",
      "0.592 1.0 1.0\n",
      "0.593 1.0 1.0\n",
      "0.594 1.0 1.0\n",
      "0.595 1.0 1.0\n",
      "0.596 1.0 1.0\n",
      "0.597 1.0 1.0\n",
      "0.598 1.0 1.0\n",
      "0.599 1.0 1.0\n",
      "0.6 1.0 1.0\n",
      "0.601 1.0 1.0\n",
      "0.602 1.0 1.0\n",
      "0.603 1.0 1.0\n",
      "0.604 1.0 1.0\n",
      "0.605 1.0 1.0\n",
      "0.606 1.0 1.0\n",
      "0.607 1.0 1.0\n",
      "0.608 1.0 1.0\n",
      "0.609 1.0 1.0\n",
      "0.61 1.0 1.0\n",
      "0.611 1.0 1.0\n",
      "0.612 1.0 1.0\n",
      "0.613 1.0 1.0\n",
      "0.614 1.0 1.0\n",
      "0.615 1.0 1.0\n",
      "0.616 1.0 1.0\n",
      "0.617 1.0 1.0\n",
      "0.618 1.0 1.0\n",
      "0.619 1.0 1.0\n",
      "0.62 1.0 1.0\n",
      "0.621 1.0 1.0\n",
      "0.622 1.0 1.0\n",
      "0.623 1.0 1.0\n",
      "0.624 1.0 1.0\n",
      "0.625 1.0 1.0\n",
      "0.626 1.0 1.0\n",
      "0.627 1.0 1.0\n",
      "0.628 1.0 1.0\n",
      "0.629 1.0 1.0\n",
      "0.63 1.0 1.0\n",
      "0.631 1.0 1.0\n",
      "0.632 1.0 1.0\n",
      "0.633 1.0 1.0\n",
      "0.634 1.0 1.0\n",
      "0.635 1.0 1.0\n",
      "0.636 1.0 1.0\n",
      "0.637 1.0 1.0\n",
      "0.638 1.0 1.0\n",
      "0.639 1.0 1.0\n",
      "0.64 1.0 1.0\n",
      "0.641 1.0 1.0\n",
      "0.642 1.0 1.0\n",
      "0.643 1.0 1.0\n",
      "0.644 1.0 1.0\n",
      "0.645 1.0 1.0\n",
      "0.646 1.0 1.0\n",
      "0.647 1.0 1.0\n",
      "0.648 1.0 1.0\n",
      "0.649 1.0 1.0\n",
      "0.65 1.0 1.0\n",
      "0.651 1.0 1.0\n",
      "0.652 1.0 1.0\n",
      "0.653 1.0 1.0\n",
      "0.654 1.0 1.0\n",
      "0.655 1.0 1.0\n",
      "0.656 1.0 1.0\n",
      "0.657 1.0 1.0\n",
      "0.658 1.0 1.0\n",
      "0.659 1.0 1.0\n",
      "0.66 1.0 1.0\n",
      "0.661 1.0 1.0\n",
      "0.662 1.0 1.0\n",
      "0.663 1.0 1.0\n",
      "0.664 1.0 1.0\n",
      "0.665 1.0 1.0\n",
      "0.666 1.0 1.0\n",
      "0.667 1.0 1.0\n",
      "0.668 1.0 1.0\n",
      "0.669 1.0 1.0\n",
      "0.67 1.0 1.0\n",
      "0.671 1.0 1.0\n",
      "0.672 1.0 1.0\n",
      "0.673 1.0 1.0\n",
      "0.674 1.0 1.0\n",
      "0.675 1.0 1.0\n",
      "0.676 1.0 1.0\n",
      "0.677 1.0 1.0\n",
      "0.678 1.0 1.0\n",
      "0.679 1.0 1.0\n",
      "0.68 1.0 1.0\n",
      "0.681 1.0 1.0\n",
      "0.682 1.0 1.0\n",
      "0.683 1.0 1.0\n",
      "0.684 1.0 1.0\n",
      "0.685 1.0 1.0\n",
      "0.686 1.0 1.0\n",
      "0.687 1.0 1.0\n",
      "0.6880000000000001 1.0 1.0\n",
      "0.6890000000000001 1.0 1.0\n",
      "0.6900000000000001 1.0 1.0\n",
      "0.6910000000000001 1.0 1.0\n",
      "0.6920000000000001 1.0 1.0\n",
      "0.6930000000000001 1.0 1.0\n",
      "0.6940000000000001 1.0 1.0\n",
      "0.6950000000000001 1.0 1.0\n",
      "0.6960000000000001 1.0 1.0\n",
      "0.6970000000000001 1.0 1.0\n",
      "0.6980000000000001 1.0 1.0\n",
      "0.6990000000000001 1.0 1.0\n",
      "0.7000000000000001 1.0 1.0\n",
      "0.7010000000000001 1.0 1.0\n",
      "0.7020000000000001 1.0 1.0\n",
      "0.7030000000000001 1.0 1.0\n",
      "0.704 1.0 1.0\n",
      "0.705 1.0 1.0\n",
      "0.706 1.0 1.0\n",
      "0.707 1.0 1.0\n",
      "0.708 1.0 1.0\n",
      "0.709 1.0 1.0\n",
      "0.71 1.0 1.0\n",
      "0.711 1.0 1.0\n",
      "0.712 1.0 1.0\n",
      "0.713 1.0 1.0\n",
      "0.714 1.0 1.0\n",
      "0.715 1.0 1.0\n",
      "0.716 1.0 1.0\n",
      "0.717 1.0 1.0\n",
      "0.718 1.0 1.0\n",
      "0.719 1.0 1.0\n",
      "0.72 1.0 1.0\n",
      "0.721 1.0 1.0\n",
      "0.722 1.0 1.0\n",
      "0.723 1.0 1.0\n",
      "0.724 1.0 1.0\n",
      "0.725 1.0 1.0\n",
      "0.726 1.0 1.0\n",
      "0.727 1.0 1.0\n",
      "0.728 1.0 1.0\n",
      "0.729 1.0 1.0\n",
      "0.73 1.0 1.0\n",
      "0.731 1.0 1.0\n",
      "0.732 1.0 1.0\n",
      "0.733 1.0 1.0\n",
      "0.734 1.0 1.0\n",
      "0.735 1.0 1.0\n",
      "0.736 1.0 1.0\n",
      "0.737 1.0 1.0\n",
      "0.738 1.0 1.0\n",
      "0.739 1.0 1.0\n",
      "0.74 1.0 1.0\n",
      "0.741 1.0 1.0\n",
      "0.742 1.0 1.0\n",
      "0.743 1.0 1.0\n",
      "0.744 1.0 1.0\n",
      "0.745 1.0 1.0\n",
      "0.746 1.0 1.0\n",
      "0.747 1.0 1.0\n",
      "0.748 1.0 1.0\n",
      "0.749 1.0 1.0\n",
      "0.75 1.0 1.0\n",
      "0.751 1.0 1.0\n",
      "0.752 1.0 1.0\n",
      "0.753 1.0 1.0\n",
      "0.754 1.0 1.0\n",
      "0.755 1.0 1.0\n",
      "0.756 1.0 1.0\n",
      "0.757 1.0 1.0\n",
      "0.758 1.0 1.0\n",
      "0.759 1.0 1.0\n",
      "0.76 1.0 1.0\n",
      "0.761 1.0 1.0\n",
      "0.762 1.0 1.0\n",
      "0.763 1.0 1.0\n",
      "0.764 1.0 1.0\n",
      "0.765 1.0 1.0\n",
      "0.766 1.0 1.0\n",
      "0.767 1.0 1.0\n",
      "0.768 1.0 1.0\n",
      "0.769 1.0 1.0\n",
      "0.77 1.0 1.0\n",
      "0.771 1.0 1.0\n",
      "0.772 1.0 1.0\n",
      "0.773 1.0 1.0\n",
      "0.774 1.0 1.0\n",
      "0.775 1.0 1.0\n",
      "0.776 1.0 1.0\n",
      "0.777 1.0 1.0\n",
      "0.778 1.0 1.0\n",
      "0.779 1.0 1.0\n",
      "0.78 1.0 1.0\n",
      "0.781 1.0 1.0\n",
      "0.782 1.0 1.0\n",
      "0.783 1.0 1.0\n",
      "0.784 1.0 1.0\n",
      "0.785 1.0 1.0\n",
      "0.786 1.0 1.0\n",
      "0.787 1.0 1.0\n",
      "0.788 1.0 1.0\n",
      "0.789 1.0 1.0\n",
      "0.79 1.0 1.0\n",
      "0.791 1.0 1.0\n",
      "0.792 1.0 1.0\n",
      "0.793 1.0 1.0\n",
      "0.794 1.0 1.0\n",
      "0.795 1.0 1.0\n",
      "0.796 1.0 1.0\n",
      "0.797 1.0 1.0\n",
      "0.798 1.0 1.0\n",
      "0.799 1.0 1.0\n",
      "0.8 1.0 1.0\n",
      "0.801 1.0 1.0\n",
      "0.802 1.0 1.0\n",
      "0.803 1.0 1.0\n",
      "0.804 1.0 1.0\n",
      "0.805 1.0 1.0\n",
      "0.806 1.0 1.0\n",
      "0.807 1.0 1.0\n",
      "0.808 1.0 1.0\n",
      "0.809 1.0 1.0\n",
      "0.81 1.0 1.0\n",
      "0.811 1.0 1.0\n",
      "0.812 1.0 1.0\n",
      "0.8130000000000001 1.0 1.0\n",
      "0.8140000000000001 1.0 1.0\n",
      "0.8150000000000001 1.0 1.0\n",
      "0.8160000000000001 1.0 1.0\n",
      "0.8170000000000001 1.0 1.0\n",
      "0.8180000000000001 1.0 1.0\n",
      "0.8190000000000001 1.0 1.0\n",
      "0.8200000000000001 1.0 1.0\n",
      "0.8210000000000001 1.0 1.0\n",
      "0.8220000000000001 1.0 1.0\n",
      "0.8230000000000001 1.0 1.0\n",
      "0.8240000000000001 1.0 1.0\n",
      "0.8250000000000001 1.0 1.0\n",
      "0.8260000000000001 1.0 1.0\n",
      "0.8270000000000001 1.0 1.0\n",
      "0.8280000000000001 1.0 1.0\n",
      "0.8290000000000001 1.0 1.0\n",
      "0.8300000000000001 1.0 1.0\n",
      "0.8310000000000001 1.0 1.0\n",
      "0.8320000000000001 0.999999975132835 1.0\n",
      "0.833 8.708150396428931e-16 1.0\n",
      "0.834 2.2731695973445358e-38 1.0\n",
      "0.835 7.162710099197694e-61 1.0\n",
      "0.836 2.7280329045632368e-83 1.0\n",
      "0.837 1.2575833508208673e-105 1.0\n",
      "0.838 7.026326376525009e-128 1.0\n",
      "0.839 4.7644724121921497e-150 1.0\n",
      "0.84 3.926341180807085e-172 1.0\n",
      "0.841 3.9376844411073547e-194 1.0\n",
      "0.842 4.8124645863678604e-216 1.0\n",
      "0.843 7.177335112885123e-238 1.0\n",
      "0.844 1.3080501387098304e-259 1.0\n",
      "0.845 2.9170822098622156e-281 1.0\n",
      "0.846 7.971404522117507e-303 1.0\n",
      "0.847 0.0 1.0\n",
      "0.848 0.0 1.0\n",
      "0.849 0.0 1.0\n",
      "0.85 0.0 1.0\n",
      "0.851 0.0 1.0\n",
      "0.852 0.0 1.0\n",
      "0.853 0.0 1.0\n",
      "0.854 0.0 1.0\n",
      "0.855 0.0 1.0\n",
      "0.856 0.0 1.0\n",
      "0.857 0.0 1.0\n",
      "0.858 0.0 1.0\n",
      "0.859 0.0 1.0\n",
      "0.86 0.0 1.0\n",
      "0.861 0.0 1.0\n",
      "0.862 0.0 1.0\n",
      "0.863 0.0 1.0\n",
      "0.864 0.0 1.0\n",
      "0.865 0.0 1.0\n",
      "0.866 0.0 1.0\n",
      "0.867 0.0 1.0\n",
      "0.868 0.0 1.0\n",
      "0.869 0.0 1.0\n",
      "0.87 0.0 1.0\n",
      "0.871 0.0 1.0\n",
      "0.872 0.0 1.0\n",
      "0.873 0.0 1.0\n",
      "0.874 0.0 1.0\n",
      "0.875 0.0 1.0\n",
      "0.876 0.0 1.0\n",
      "0.877 0.0 1.0\n",
      "0.878 0.0 1.0\n",
      "0.879 0.0 1.0\n",
      "0.88 0.0 1.0\n",
      "0.881 0.0 1.0\n",
      "0.882 0.0 1.0\n",
      "0.883 0.0 1.0\n",
      "0.884 0.0 1.0\n",
      "0.885 0.0 1.0\n",
      "0.886 0.0 1.0\n",
      "0.887 0.0 1.0\n",
      "0.888 0.0 1.0\n",
      "0.889 0.0 1.0\n",
      "0.89 0.0 1.0\n",
      "0.891 0.0 1.0\n",
      "0.892 0.0 1.0\n",
      "0.893 0.0 1.0\n",
      "0.894 0.0 1.0\n",
      "0.895 0.0 1.0\n",
      "0.896 0.0 1.0\n",
      "0.897 0.0 1.0\n",
      "0.898 0.0 1.0\n",
      "0.899 0.0 1.0\n",
      "0.9 0.0 1.0\n",
      "0.901 0.0 1.0\n",
      "0.902 0.0 1.0\n",
      "0.903 0.0 1.0\n",
      "0.904 0.0 1.0\n",
      "0.905 0.0 1.0\n",
      "0.906 0.0 1.0\n",
      "0.907 0.0 1.0\n",
      "0.908 0.0 1.0\n",
      "0.909 0.0 1.0\n",
      "0.91 0.0 1.0\n",
      "0.911 0.0 1.0\n",
      "0.912 0.0 1.0\n",
      "0.913 0.0 1.0\n",
      "0.914 0.0 1.0\n",
      "0.915 0.0 1.0\n",
      "0.916 0.0 1.0\n",
      "0.917 0.0 1.0\n",
      "0.918 0.0 1.0\n",
      "0.919 0.0 1.0\n",
      "0.92 0.0 1.0\n",
      "0.921 0.0 1.0\n",
      "0.922 0.0 1.0\n",
      "0.923 0.0 1.0\n",
      "0.924 0.0 1.0\n",
      "0.925 0.0 1.0\n",
      "0.926 0.0 1.0\n",
      "0.927 0.0 1.0\n",
      "0.928 0.0 1.0\n",
      "0.929 0.0 1.0\n",
      "0.93 0.0 1.0\n",
      "0.931 0.0 1.0\n",
      "0.932 0.0 1.0\n",
      "0.933 0.0 1.0\n",
      "0.934 0.0 1.0\n",
      "0.935 0.0 1.0\n",
      "0.936 0.0 1.0\n",
      "0.937 0.0 1.0\n",
      "0.9380000000000001 0.0 1.0\n",
      "0.9390000000000001 0.0 1.0\n",
      "0.9400000000000001 0.0 1.0\n",
      "0.9410000000000001 0.0 1.0\n",
      "0.9420000000000001 0.0 1.0\n",
      "0.9430000000000001 0.0 1.0\n",
      "0.9440000000000001 0.0 1.0\n",
      "0.9450000000000001 0.0 1.0\n",
      "0.9460000000000001 0.0 1.0\n",
      "0.9470000000000001 0.0 1.0\n",
      "0.9480000000000001 0.0 1.0\n",
      "0.9490000000000001 0.0 1.0\n",
      "0.9500000000000001 0.0 1.0\n",
      "0.9510000000000001 0.0 1.0\n",
      "0.9520000000000001 0.0 1.0\n",
      "0.9530000000000001 0.0 1.0\n",
      "0.9540000000000001 0.0 1.0\n",
      "0.9550000000000001 0.0 1.0\n",
      "0.9560000000000001 0.0 1.0\n",
      "0.9570000000000001 0.0 1.0\n",
      "0.9580000000000001 0.0 1.0\n",
      "0.9590000000000001 0.0 1.0\n",
      "0.96 0.0 1.0\n",
      "0.961 0.0 1.0\n",
      "0.962 0.0 1.0\n",
      "0.963 0.0 1.0\n",
      "0.964 0.0 1.0\n",
      "0.965 0.0 1.0\n",
      "0.966 0.0 0.5786634101681737\n",
      "0.967 0.0 2.02763896731303e-22\n",
      "0.968 0.0 1.6902950347717173e-87\n",
      "0.969 0.0 1.4090759502220884e-152\n",
      "0.97 0.0 1.1746440666569385e-217\n",
      "0.971 0.0 9.792152673636065e-283\n",
      "0.972 0.0 0.0\n",
      "0.973 0.0 0.0\n",
      "0.974 0.0 0.0\n",
      "0.975 0.0 0.0\n",
      "0.976 0.0 0.0\n",
      "0.977 0.0 0.0\n",
      "0.978 0.0 0.0\n",
      "0.979 0.0 0.0\n",
      "0.98 0.0 0.0\n",
      "0.981 0.0 0.0\n",
      "0.982 0.0 0.0\n",
      "0.983 0.0 0.0\n",
      "0.984 0.0 0.0\n",
      "0.985 0.0 0.0\n",
      "0.986 0.0 0.0\n",
      "0.987 0.0 0.0\n",
      "0.988 0.0 0.0\n",
      "0.989 0.0 0.0\n",
      "0.99 0.0 0.0\n",
      "0.991 0.0 0.0\n",
      "0.992 0.0 0.0\n",
      "0.993 0.0 0.0\n",
      "0.994 0.0 0.0\n",
      "0.995 0.0 0.0\n",
      "0.996 0.0 0.0\n",
      "0.997 0.0 0.0\n",
      "0.998 0.0 0.0\n",
      "0.999 0.0 0.0\n",
      "1.0 0.0 0.0\n"
     ]
    }
   ],
   "source": [
    "epsilonMu=5\n",
    "leader_probs=[]\n",
    "follower_probs=[]\n",
    "leader_payoffs=[]\n",
    "follower_payoffs=[]\n",
    "\n",
    "\n",
    "for FS in range(1001):\n",
    "    \n",
    "    guessl=1\n",
    "    guessf=1\n",
    "\n",
    "    mu=0\n",
    "    \n",
    "    if FS==0:\n",
    "        prob=.5\n",
    "        mu=0\n",
    "        for i in range(1000):\n",
    "            [prob,payoff]=last_period_0(0,[prob])\n",
    "            mu=mu+epsilonMu\n",
    "        leader_probs.append(prob)\n",
    "        follower_probs.append(prob)\n",
    "        leader_payoffs.append(payoff)\n",
    "        follower_payoffs.append(payoff)\n",
    "        print(.001*FS,prob,prob)\n",
    "    \n",
    "    if FS>0:\n",
    "        for i in range(1000):\n",
    "            [guessl,guessf,payoffL,payoffF]=last_period(.001*FS,[guessl,guessf])\n",
    "            mu=mu+epsilonMu\n",
    "        leader_probs.append(guessl)\n",
    "        follower_probs.append(guessf)\n",
    "        leader_payoffs.append(payoffL)\n",
    "        follower_payoffs.append(payoffF)\n",
    "        print(.001*FS,guessl,guessf)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('Alternative_Follower_Prob_Period_%s_%s_%s_%s.pkl'%(period,N,v,c), 'wb') as f:\n",
    "    pickle.dump(follower_probs,f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('Alternative_Leader_Prob_Period_%s_%s_%s_%s.pkl'%(period,N,v,c), 'wb') as f:\n",
    "    pickle.dump(leader_probs,f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('Alternative_Follower_Payoffs_Period_%s_%s_%s_%s.pkl'%(period,N,v,c), 'wb') as f:\n",
    "    pickle.dump(follower_payoffs,f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('Alternative_Leader_Payoffs_Period_%s_%s_%s_%s.pkl'%(period,N,v,c), 'wb') as f:\n",
    "    pickle.dump(leader_payoffs,f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
